﻿using System.Web;
using System.Web.Mvc;
using HCQ2UI_Helper;

namespace HCQ2UI_Logic
{
    /// <summary>
    ///  控制器父类
    /// </summary>
    public class BaseLogic: Controller
    {
        /// <summary>
        ///  是否属于中文语言
        /// </summary>
        public bool isChinese
        {
            get
            {
                return HCQ2UI_Helper.Session.SysPermissSession.isChinese;
            }
        }
        protected string getErrorMessage(ModelStateDictionary ModelState)
        {
            if (ModelState.IsValid)
                return string.Empty;
            string message = string.Empty;
            foreach (var s in ModelState.Values)
            {
                foreach (var p in s.Errors)
                {
                    message = p.ErrorMessage;
                    if (string.IsNullOrEmpty(message))
                        message = "传递参数异常错误消息：" + p.Exception.Message.ToString();
                    return message;
                }
            }
            return string.Empty;
        }
        /// <summary>
        /// 获取操作上下文对象
        /// </summary>
        protected OperateContext operateContext
        {
            get { return OperateContext.Current; }
        }
        protected HttpRequestBase request
        {
            get { return Request; }
        }
    }
}
